from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet

from user_app.serializers.permission_contype import PermissonContypeSerializer
from user_app.serializers.permisson import PermissonSerializer
from utils.rest_pagination import MyPagination


class PermissionView(ModelViewSet):
    queryset = Permission.objects.all()
    serializer_class = PermissonSerializer
    pagination_class = MyPagination

    def get_permission_contype(self, request):
        query = ContentType.objects.all()
        ser = PermissonContypeSerializer(query, many=True)
        return Response(ser.data)
